package com.jp.knowledge.adapter;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;

import com.jp.knowledge.R;
import com.jp.knowledge.model.VipGrade;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;

import java.util.List;

/**
 * Created by jiayen on 17/6/1.
 */

public class VipGradeAdapter extends RecycleVAdapter<VipGrade> {

    private int selectedPosition;

    public VipGradeAdapter(Context context, List infos) {
        super(context, infos);
        selectedPosition = -1;
    }

    @Override
    public int getLayoutId(int position) {
        return R.layout.vip_layout_item;
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        VipGrade item = getData(position);
        holder.setTextView(R.id.vip_buy_one_year_title,item.getPackageTitle());
        holder.setTextView(R.id.vip_buy_one_year_money,"￥"+String.format("%.2f",item.getPackagePrice()/100.00));
        holder.setTextView(R.id.vip_description,item.getPackageDesc());
        CheckBox checkBox =  holder.get(R.id.vip_buy_one_year_cb);
        checkBox.setChecked(selectedPosition == position);
    }

    public int getSelectedPosition() {
        return selectedPosition;
    }

    public void setSelectedPosition(int selectedPosition) {
        this.selectedPosition = selectedPosition;
    }
}
